import '@/style/index.scss'
import '@/style/custom/main.css'
import '@/style/custom/icon.css'
import '@/style/custom/animation.css'
import { VueQueryPlugin } from '@tanstack/vue-query'
import 'virtual:uno.css'
import { createSSRApp } from 'vue'

import App from './App.vue'
import { prototypeInterceptor, requestInterceptor, routeInterceptor } from './interceptors'
import { registerGlobComp } from '@/components/registerGlobComp'
import store from './store'
import router from './router'
import { setupAuthDirective } from '@/directives/auth'

export function createApp() {
  try {
    const app = createSSRApp(App)
    app.use(store)
    app.use(router)
    app.use(routeInterceptor)
    app.use(requestInterceptor)
    app.use(prototypeInterceptor)
    app.use(VueQueryPlugin)
    //#ifndef MP-WEIXIN
    // 注册全局组件
    registerGlobComp(app)
    // 注册权限指令
    setupAuthDirective(app)
    // #endif
    return {
      app,
    }
  } catch (error) {
    console.log(error)
  }
}
